using UnityEngine;
using System.Collections;

public class GridScript : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		//Debug.DrawRay( transform.position, m.normals[0] );
	
	}
	
	public void InitGrid( GameMsgScript.GridType type, Texture2D defTex, Texture2D focTex )
	{
		MeshRenderer mesh = GetComponent<MeshRenderer>() as MeshRenderer;
		gridMaterial = mesh.material;
		defaultTex = defTex;
		focusTex = focTex;
		gridMaterial.mainTexture = defTex;
		
		
		MeshFilter mf = GetComponent<MeshFilter>();
		m = mf.mesh;
	}
	
	public void SetFocus(bool focus)
	{
		if ( focus )
			gridMaterial.mainTexture = focusTex ;
		else
			gridMaterial.mainTexture = defaultTex;
	}
	
	
	public GameMsgScript.GridType	gridType;
	public Material					gridMaterial;
	public Texture2D				defaultTex;
	public Texture2D				focusTex;
	
	public Mesh						m;
}
